package com.gmzg.gmzgnews.live.view;


import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gmzg.gmzgnews.R;
import com.gmzg.gmzgnews.live.adapter.CommonFragmentPagerAdapter;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * A simple {@link Fragment} subclass.
 */
public class LiveFragment extends Fragment {


    @BindView(R.id.live_tab)
    TabLayout mLiveTab;
    @BindView(R.id.live_view_pager)
    ViewPager mLiveViewPager;

    public LiveFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_live, container, false);
        ButterKnife.bind(this, view);

        mLiveTab.setSelectedTabIndicatorColor(getResources().getColor(R.color.red));
        mLiveTab.setTabTextColors(ColorStateList.valueOf(getResources().getColor(R.color.white)));

        ArrayList<BaseFragment> fragments = new ArrayList<>();
//        fragments.add(new HotTopFragment());
        fragments.add(new HotTopFragmentWithCache());
//        fragments.add(new CategoryFragment());

        CommonFragmentPagerAdapter adapter = new CommonFragmentPagerAdapter(
                getChildFragmentManager(),
                fragments
        );

        mLiveViewPager.setAdapter(adapter);

        mLiveTab.setupWithViewPager(mLiveViewPager);

        return view;
    }

}
